package bigraph.part;

import java.beans.PropertyChangeEvent;
import java.util.List;

import org.eclipse.draw2d.IFigure;
import org.eclipse.gef.EditPolicy;

import bigraph.editpolicies.AppEditLayoutPolicy;
import bigraph.figure.CanvasFigure;
import bigraph.model.Canvas;
import bigraph.model.Node;

public class CanvasPart extends AppAbstractEditPart {

	@Override
	protected IFigure createFigure() {
		IFigure figure = new CanvasFigure();
		return figure;
	}

	@Override
	protected void createEditPolicies() {
		installEditPolicy(EditPolicy.LAYOUT_ROLE, new AppEditLayoutPolicy());
	}
	
	protected void refreshVisuals(){
	     CanvasFigure figure = (CanvasFigure)getFigure();
	     Canvas model = (Canvas)getModel();
	}
	public List<Node> getModelChildren() {
	    return ((Canvas)getModel()).getChildrenArray();
	}
	
	@Override
	public void propertyChange(PropertyChangeEvent evt) {
	     if (evt.getPropertyName().equals(Node.PROPERTY_LAYOUT)) refreshVisuals();
	     if (evt.getPropertyName().equals(Node.PROPERTY_ADD)) refreshChildren();
	     if (evt.getPropertyName().equals(Node.PROPERTY_REMOVE)) refreshChildren();
	}



}
